FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app

ENV HTTP_PROXY "http://ex_gaomeng:gaomeng.320@10.68.211.5:80/"
ENV HTTPS_PROXY "http://ex_gaomeng:gaomeng.320@10.68.211.5:80/"

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM microsoft/dotnet:aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "NetCoreWebApi.dll"]